package com.wtf.dsp.admin.enums;

import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 公共异常错误码枚举类
 * date: 2022/6/18 10:59
 * @author linhuanyou
 * @email 496558736@qq.com
 * @version 1.0
 */
public enum CommonErrorEnum {
    SUCCESS(0,"操作成功"),

    ERROR_THIRD_PLATFORM_NOT_EXIST(401,"认证平台不存在"),
    ERROR_STATE(401,"状态码错误"),
    ERROR_NOT_LOGIN(401,"请先登录！"),
    ERROR_LOGIN_EXP(401,"登录已失效，请重新！"),
    PERMISSION_DENIED(403,"权限不足"),
    ADMIN_PERMISSION_DENIED(403,"请联系管理员操作"),
    LOGIN_PERMISSION_DENIED(403,"仅系统管理员或者本人才允许操作"),


    BIZ_ERROR(500,"业务异常"),

    USER_EXIST(400000,"用户已存在"),
    USER_NOT_EXIST(400001,"用户不存在"),
    PASSWORD_ERROR(400002,"旧密码错误"),
    OLD_AND_NEW_PASSWORD_ERROR(400003,"旧密码与新密码一致"),
    ADMIN_USERNAME(400004,"管理员账号不可删除"),
    USERNAME_OR_PASSWORD_ERROR(400005,"用户名或密码错误"),


    SYSTEM_BUSY(500001, "系统繁忙，请稍候再试"),
    OPERATION_ERRO(500002,"操作失败"),
    ERROR_NULL(500003,"空指针错误!"),
    ERROR_VALID(500004,"参数错误!"),
    ERROR_REQUEST_METHOD_NOT_SUPPORTED(500005,"请求方式错误!"),
    ERROR_NETWORK(500006,"网络异常!"),
    ERROR_EXCEL(500007,"Excel解析错误"),
    ERROR_INVAILD_CHAR(500008,"非法字符"),
    ERROR_DUPLICATE_KEY(500009,"数据重复"),
    ERROR_BAS_REQUEST(500010,"非法请求"),
    ERROR_XML_PARSE(500011,"XML解析异常"),
    ERROR_PAGE_SELECT_SQL(500012,"分页查询必须是SELECT查询语句"),
    ERROR_DBTYPE(500013,"数据库类型不存在"),
    ERROR_DB(500014,"数据库操作异常"),
    ERROR_NOT_FIND_DS(500015,"数据源不存在"),
    ERROR_PRIMARY_DS(500016,"主数据源无法操作"),
    OPEN_CONNECTION_EXCEPTION(500017,"连接失败，请检查主机、账号、密码、数据库是否正确"),
    CLOSE_CONNECTION_EXCEPTION(500018,"数据库连接关闭异常"),
    NAMESPACE_EXIST(500019,"命名空间已存在"),
    NAMESPACE_NOT_EXIST(500020,"命名空间不存在，请先创建命名空间"),
    TARGET_NAMESPACE_NOT_EXIST(500020,"目标命名空间不存在，请先创建命名空间"),
    DATA_SOURCE_EXIST(500021,"数据源已存在"),
    TARGET_DATA_SOURCE_EXIST(500021,"目标数据源已存在"),
    DATA_SOURCE_NOT_EXIST(500022,"数据源不存在，请先创建数据源"),
    MAPPER_EXIST(500023,"Mapper资源已存在"),
    TARGET_MAPPER_EXIST(500023,"Mapper资源已存在"),
    MAPPER_NOT_EXIST(500024,"Mapper资源不存在，请先创建Mapper资源"),
    MAPPER_SQL_EXIST(500025,"SQL已存在"),
    MAPPER_SQL_NOT_EXIST(500026,"SQL不存在，请先创建SQL"),
    MAPPER_SQL_VALIDATE(500027,"SQL非法"),
    EXECUTOR_SQL_ERROR(500028,"SQL执行异常"),
    DEFAULT_NAMESPACE_ERROR(500029,"默认空间不可编辑"),
    DEFAULT_NAMESPACE_DEL_ERROR(500029,"public空间不可删除"),
    NAMESPACE_DS_ERROR(500030,"命名空间存在数据源，请先清空数据源"),
    DS_MAPPER_ERROR(500030,"数据源存在Mapper，请先清空Mapper"),
    HIKARI_POOL_ERROR(500031,"数据库连接池异常"),
    DB_CONFIG_ERROR(500032,"数据库配置缺失"),
    DB_DRIVER_ERROR(500032,"数据库驱动缺失,请联系系统管理员升级"),
    DB_CONFIG_EXIST(500033,"数据库配置已存在"),
    DB_CONFIG_NOT_EXIST(500034,"数据库配置不存在"),
    ;
    @JsonValue
    private int errCode;

    private String errMsg;

    CommonErrorEnum(int errCode, String errMsg) {
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public int getErrCode() {
        return errCode;
    }

    public void setErrCode(int errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }
}
